package com.tuju.jetpackfirstdemo.widget

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import android.graphics.Shader
import android.graphics.RadialGradient
import android.graphics.LinearGradient
import android.util.Log


class VolumeView(context:Context,attributeset: AttributeSet) : View(context,attributeset) {
    private lateinit var paint:Paint

    init {
        paint = Paint()
        paint.color = Color.BLUE
        paint.style = Paint.Style.FILL
        Log.i("yanze","init 高：${height} 宽：${width}")
//        paint.setStrokeWidth(20f)
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        val squeShader = LinearGradient(0f, 0f, 0f, height.toFloat(), Color.parseColor("#ffffff"),
                Color.parseColor("#000000"), Shader.TileMode.CLAMP)
        paint.shader = squeShader
        Log.i("yanze","onDraw 高：${height} 宽：${width}")
//        canvas?.drawCircle((width / 2).toFloat(),(height / 2).toFloat(),100f,paint)
        canvas.drawOval(0f, 0f, width.toFloat(), bottom.toFloat(), paint)
    }

}